package cn.ekuma.epos.report;

import java.awt.Component;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Window;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import com.openbravo.pos.util.JTableViewer300;

/**
 *
 * @author Administrator
 */
public class JTableReportDialog extends javax.swing.JDialog {




    /** Creates new form JTicketChangeRateDialog 
     * @wbp.parser.constructor*/
    public JTableReportDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
    }

     /** Creates new form JProductLineKeyBoardEdit */
    private  JTableReportDialog(java.awt.Dialog parent, boolean modal) {
        super(parent, modal);
    }
 
    public static JTableReportDialog getDialog(Component parent) {
        Window window = SwingUtilities.getWindowAncestor(parent);
        JTableReportDialog myMsg;
        if (window instanceof Frame) {
            myMsg = new JTableReportDialog((Frame) window, true);
        } else {
            myMsg = new JTableReportDialog((Dialog) window, true);
        }
        myMsg.applyComponentOrientation(parent.getComponentOrientation());
        return myMsg;
    }

    private void init(JTable jrPrint){
        initComponents();
        final JTableViewer300 viewer=new JTableViewer300(jrPrint);
        jPanel1.add(viewer, java.awt.BorderLayout.CENTER);
        this.addWindowListener(new WindowListener(){

			@Override
			public void windowOpened(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void windowClosing(WindowEvent e) {
				
			}

			@Override
			public void windowClosed(WindowEvent e) {
				viewer.resertJTableSytle();
			}

			@Override
			public void windowIconified(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void windowDeiconified(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void windowActivated(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void windowDeactivated(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}
        	
        });
    }

    public static void showReport(Component aThis, JTable jp) {
    	JTableReportDialog reportDialog=getDialog(aThis);
        reportDialog.init(jp);
        reportDialog.setVisible(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setLayout(new java.awt.BorderLayout());
        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-842)/2, (screenSize.height-600)/2, 842, 600);
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

}
